/*
 *   This File is Part of CuteOgre Game Engine
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *	Copyright 2010 Alexandre Pires ( c.alexandre.pires@gmail.com )
 *  Created on: 2010/09/04
 */

#ifndef STYLESHEET_H_
#define STYLESHEET_H_

#include <QString>
#include <QMap>

class StyleSheetManager;
class Style;

class StyleSheet {

	friend class StyleSheetManager;

	typedef QMap<QString, Style> StylesMap;

private:
	QString mName;
	StylesMap mStyles;

protected:
	StyleSheet ( const QString& rFile );

private:
	QString readFileContents ( const QString& rFile );
	void parseFile ( const QString& rFile );
	bool parseDirective ( const QString& rFile, const QString& rContents, int* rOffset, int* rLine, int* rCol );
	bool parseComment ( const QString& rFile, const QString& rContents, int* rOffset, int* rLine, int* rCol );
	bool parseSection ( const QString& rFile, const QString& rContents, Style* rStyle, int* rOffset, int* rLine, int* rCol );
	QString parseValue ( const QString& rFile, const QString& rContents, int* rOffset, int* rLine, int* rCol );

public:
	~StyleSheet ();

	inline void reload () {
		parseFile ( mName );
	}

	Style getStyle ( const QString& rName ) const;
};

#endif /* STYLESHEET_H_ */
